<?php
class Accountsstatus_Model_Pagedecision implements Accountsstatus_Model_Mainable{
    
    private $action_handler;
    private $csrf_token;
    
    public function main(array $variables = null) {
        switch ($variables['get']['page']){
            case "dodaj":
                return $this->add_account_status($variables);
                break;
            case "wstaw":
                return $this->insert_account_status($variables);
                break;
            case "edytuj":
                return $this->edit_account_status($variables);
                break;
            case "aktualizuj":
                return $this->update_account_status($variables);
                break;
            case "usun":
                return $this->delete_account_status($variables);
                break;
            default:
                return $this->default_action($variables);
                break;
        }
    }
    
    private function delete_account_status(array $variables = null){
        $this->action_handler = new Accountsstatus_Model_Deleteaccountstatus;
        return $this->action_handler->main($variables);
    }
    
    private function update_account_status(array $variables = null){
        $this->action_handler = new Accountsstatus_Model_Updatestatusaction;
        return $this->action_handler->main($variables);
    }
    
    private function edit_account_status(array $variables = null){
        if(isset($variables['get']['name'])){
            $page['template'] = WEB_ROOT_FOLDER."accountsstatus/views/add.php";
            $this->action_handler = new Accountsstatus_Data_Currentaccountstatus;
            $page['content'] = $this->action_handler->main($variables);
            $this->csrf_token = new Core_Controller_Csrftoken;
            $page['csrf_token'] = $this->csrf_token->main($variables);
            return $page;
        }
        else {
            return $this->default_action($variables);
        }
    }
    
    private function insert_account_status(array $variables = null){
        $this->action_handler = new Accountsstatus_Model_Insertstatusaction;
        return $this->action_handler->main($variables);
    }
    
    private function add_account_status(array $variables = null){
        $page['template'] = "./accountsstatus/views/add.php";
        $this->csrf_token = new Core_Controller_Csrftoken;
        $page['csrf_token'] = $this->csrf_token->main($variables);
        return $page;
    }
    
    private function default_action(array $variables = null){
        unset($variables);
        $this->action_handler = new Accountsstatus_Model_Accountsstatus;
        return $this->action_handler->main($variables);
    }

}
